package com.yxhl.km.module.home.mvp;

import com.yxhl.km.http.retrofit.IEssenceService;
import com.yxhl.km.module.home.entity.HomeBean;
import com.yxhl.km.module.person.entity.UploadBean;
import com.yxhl.km.module.person.entity.UserInfo;
import com.yxhl.km.module.utils.ToastUtil;
import com.yxhl.km.mvp.BaseModel;

import java.util.List;

import okhttp3.MultipartBody;
import rx.android.schedulers.AndroidSchedulers;
import rx.functions.Action1;
import rx.schedulers.Schedulers;

/**
 * Created by 张亚楠 on 2018/5/21.
 */

public class PersonMoudle extends BaseModel {
    /**
     * @param offset
     * @param limit
     * @param onResultobj
     */

    public void getListData(String offset, String limit, final ResultBean<HomeBean> onResultobj) {
        buildService(IEssenceService.class)
                .getHomeList(offset, limit)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Action1<HomeBean>() {
                    @Override
                    public void call(HomeBean homeBean) {
                        onResultobj.onResult(homeBean);
                    }
                }, new Action1<Throwable>() {
                    @Override
                    public void call(Throwable throwable) {
                        throwableHandler(throwable);
                    }
                });
    }

    public void throwableHandler(Throwable e) {
        ToastUtil.makeToast(e.getMessage());
    }
}
